package budo;

import java.util.concurrent.Callable;

import org.budo.spring.cache.interceptor.config.BudoSpringEhCacheInterceptorConfigurer;

import com.alibaba.fastjson.JSON;

import lombok.extern.slf4j.Slf4j;

/**
 * 自动配置
 * 
 * @author limingwei
 */
@Slf4j
public class Cache extends BudoSpringEhCacheInterceptorConfigurer {
    public static String json(Object args) {
        return JSON.toJSONString(args);
    }

    public static <T> T wrap(String cacheKey, Callable<T> callable) {
        log.info("#17 Cache.wrap, cacheKey=" + cacheKey + ", callable=" + callable);

        try {
            return callable.call();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}